
var User = require('../models').User;

/**
 * 根据ID查询
 **/
exports.getUserById = function (id, callback) {
    User.findOne({_id: id}, callback);
}

/**
 * 根据用户名查询
 **/
exports.getUserByUsername = function (username, callback) {
    User.findOne({username: username}, callback);
}

/**
 * 新增用户
 **/
exports.createUser = function (username, password, callback) {
    var user = new User();
    user.username = username;
    user.password = password;
    user.save(callback);
}